import request from '@/config/axios'

export interface RefundActivityRespVO {
  id: number
  name: string
  startTime: string
  endTime: string
  punchCardRule: number
  punchCardDays?: number
  everydayPunchPeriods?: string
  activityUploadProof: boolean
  proofCheck: boolean
  notifyCopy?: string
  activityRule?: string
  status: number
  createTime: string
  products: Product[]
}

export interface RefundActivityCreateReqVO {
  name: string
  startTime: number
  endTime: number
  punchCardRule: number
  punchCardDays?: number
  everydayPunchPeriods?: string
  activityUploadProof: boolean
  proofCheck: boolean
  notifyCopy?: string
  activityRule?: string
  products: Product[]
}

export interface RefundActivityUpdateReqVO extends RefundActivityCreateReqVO {
  id: number
}

export interface Product {
  spuId: number
}

export interface RefundActivityPageReqVO extends PageParam {
  name?: string
  status?: number
  createTime?: string[]
}

// 获得退款活动分页
export const getRefundActivityPage = (params: RefundActivityPageReqVO) => {
  return request.get<{
    list: RefundActivityRespVO[]
    total: number
  }>({ url: '/promotion/refund-activity/page', params })
}

// 查询退款活动详情
export const getRefundActivity = (id: number) => {
  return request.get<RefundActivityRespVO>({ url: `/promotion/refund-activity/get?id=${id}` })
}

// 新增退款活动
export const createRefundActivity = (data: RefundActivityCreateReqVO) => {
  return request.post<number>({ url: '/promotion/refund-activity/create', data })
}

// 修改退款活动
export const updateRefundActivity = (data: RefundActivityUpdateReqVO) => {
  return request.put<boolean>({ url: '/promotion/refund-activity/update', data })
}

// 关闭退款活动
export const closeRefundActivity = (id: number) => {
  return request.put({ url: `/promotion/refund-activity/close?id=${id}` })
}

// 删除退款活动
export const deleteRefundActivity = (id: number) => {
  return request.delete({ url: `/promotion/refund-activity/delete?id=${id}` })
}

// 更新退款活动状态
export const updateRefundActivityStatus = (id: number, status: number) => {
  return request.put({ url: `/promotion/refund-activity/update-status?id=${id}&status=${status}` })
} 